package order

import (
	"github.com/xinliangnote/go-gin-api/internal/pkg/core"
	"github.com/xinliangnote/go-gin-api/internal/repository/mysql"
	"github.com/xinliangnote/go-gin-api/internal/repository/mysql/order"

)

type ModifyOrderData struct {
	OrderNo                string // 订单编号
	OrderFee                int32 // 订单金额
}

func (s *service) Modify(ctx core.Context, id int32, modifyData *ModifyOrderData) (err error) {
	data := map[string]interface{}{
		"order_no":                  modifyData.OrderNo,
		"order_fee":                  modifyData.OrderFee,	
		"updated_user":          ctx.SessionUserInfo().UserName,
	}

	qb := order.NewQueryBuilder()
	qb.WhereId(mysql.EqualPredicate, id)
	err = qb.Updates(s.db.GetDbW().WithContext(ctx.RequestContext()), data)
	if err != nil {
		return err
	}

	return
}
